package com.rephilo.code.controller;

import com.rephilo.code.service.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/code")
public class CodeController {

    @Autowired
    private CodeService codeService;

    @PostMapping("/create/{email}")
    public Boolean create(@PathVariable String email) {
        return codeService.create(email);
    }

    @GetMapping("/validate/{email}/{code}")
    public Integer validate(@PathVariable String email,
                            @PathVariable String code) {
        return codeService.validate(email, code);
    }
}
